//
//  genet-functions.c
//  PyroTools
//
//  Created by Timothée Poisot on 12/07/11.
//  Copyright 2011 Université Montpellier 2. All rights reserved.
//

#include "genet-functions.h"

// Get uncorrected pairwise distances
// this function measures SIMILARITY then
// transforms it into a distance !
double genetdist (char *s1, char *s2, int bp)
{
    char b1;
    char b2;
    double dist = 0;
    int trueDist = 0;
    for(int base=0;base<bp;++base)
    {
        b1 = s1[base];
        b2 = s2[base];
        if((b1=='a')||(b1=='t')||(b1=='g')||(b1=='c')||(b1=='-'))
        {
            ++trueDist;
            if(b1 == b2)
            {
                ++dist;
            }
        }
    }
    dist = dist / trueDist;
    dist = 1 - dist;
    return dist;
} 
